
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.AfcOrgDao;
import com.primeton.eos.oss.model.newdataset.AfcOrg;

@Service
public class AfcOrgService {

    @Autowired
    private AfcOrgDao afcOrgDao;


    public PageResultList<AfcOrg> queryAfcOrgsWithPage(String code,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return afcOrgDao.queryAfcOrgsWithPage(code,  pageSize, pageIndex);
    }

    public AfcOrg getAfcOrgById(String id) {
        //TODO 记录日志
        return afcOrgDao.getEntity(AfcOrg.QNAME, id);
    }

    @Transactional
    public void createAfcOrg(AfcOrg afcOrg) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcOrg.set("createUser", userName);
        afcOrg.set("createTime", new Date());
        afcOrg.set("updateUser", userName);
        afcOrg.set("updateTime", new Date());

        afcOrgDao.getPrimaryKey(afcOrg);
        afcOrgDao.insertEntity(afcOrg);
    }
    
    @Transactional
    public void modifyAfcOrg(AfcOrg afcOrg) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcOrg.set("updateUser", userName);
        afcOrg.set("updateTime", new Date());
 
        afcOrgDao.updateEntity(afcOrg);
    }
    
     @Transactional
    public void removeAfcOrg(AfcOrg[] afcOrg) {
        //TODO 记录日志
        afcOrgDao.deleteEntity(afcOrg);
    }

}





